Efficiently using memory for java collection objects

ABSTRACT

A method for collection instance resizing. The method may include identifying at least one collection object within a collection framework of a virtual machine. The method may also include determining the at least one identified collection object satisfies at least one preconfigured criteria. The method may further include determining a garbage collection cycle count associated with the at least one identified collection object exceeds a preconfigured threshold. The method may also include determining an occupancy ratio associated with the at least one identified collection object is less than a preconfigured shrink threshold. The method may further include restructuring the at least one identified collection object based on the at least one identified collection object satisfying the at least one preconfigured criteria, the garbage collection cycle count exceeding the preconfigured threshold, and the occupancy ratio being less than the preconfigured shrink threshold.

BACKGROUND

The present invention relates generally to the field of computing, andmore particularly to virtual machine garbage collection.

Garbage collection in a virtual machine environment, such as a Javavirtual machine (JVM), relates to an automatic process that managesruntime memory used by programs. Garbage collection may relieveprogrammer overhead required to deallocate resources in a program. TheJava collections framework provides an efficient organization andutilization of real world data and JVM provides efficient allocation anddeallocation mechanisms. The Java collections framework may be a groupof classes and interfaces implementing a set of frequently used andreusable data structures.

SUMMARY

According to one embodiment, a method for collection instance resizing.The method may include identifying at least one collection object withina collection framework of a virtual machine. The method may also includedetermining the at least one identified collection object satisfies atleast one preconfigured criteria. The method may further includedetermining a garbage collection cycle count associated with the atleast one identified collection object exceeds a preconfiguredthreshold. The method may also include determining an occupancy ratioassociated with the at least one identified collection object is lessthan a preconfigured shrink threshold. The method may further includerestructuring the at least one identified collection object based on theat least one identified collection object satisfying the at least onepreconfigured criteria, the garbage collection cycle count exceeding thepreconfigured threshold, and the occupancy ratio being less than thepreconfigured shrink threshold.

According to another embodiment, a computer system for collectioninstance resizing. The computer system may include one or moreprocessors, one or more computer-readable memories, one or morecomputer-readable tangible storage devices, and program instructionsstored on at least one of the one or more storage devices for executionby at least one of the one or more processors via at least one of theone or more memories, whereby the computer system is capable ofperforming a method. The computer system may include identifying atleast one collection object within a collection framework of a virtualmachine. The computer system may also include determining the at leastone identified collection object satisfies at least one preconfiguredcriteria. The computer system may further include determining a garbagecollection cycle count associated with the at least one identifiedcollection object exceeds a preconfigured threshold. The computer systemmay also include determining an occupancy ratio associated with the atleast one identified collection object is less than a preconfiguredshrink threshold. The computer system may further include restructuringthe at least one identified collection object based on the at least oneidentified collection object satisfying the at least one preconfiguredcriteria, the garbage collection cycle count exceeding the preconfiguredthreshold, and the occupancy ratio being less than the preconfiguredshrink threshold.

According to yet another embodiment, a computer program product forcollection instance resizing. The computer program product may includeone or more computer-readable storage devices and program instructionsstored on at least one of the one or more tangible storage devices, theprogram instructions executable by a processor. The computer programproduct may include program instructions to identify at least onecollection object within a collection framework of a virtual machine.The computer program product may also include program instructions todetermine the at least one identified collection object satisfies atleast one preconfigured criteria. The computer program product mayfurther include program instructions to determine a garbage collectioncycle count associated with the at least one identified collectionobject exceeds a preconfigured threshold. The computer program productmay also include program instructions to determine an occupancy ratioassociated with the at least one identified collection object is lessthan a preconfigured shrink threshold. The computer program product mayfurther include program instructions to restructure the at least oneidentified collection object based on the at least one identifiedcollection object satisfying the at least one preconfigured criteria,the garbage collection cycle count exceeding the preconfiguredthreshold, and the occupancy ratio being less than the preconfiguredshrink threshold.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

These and other objects, features and advantages of the presentinvention will become apparent from the following detailed descriptionof illustrative embodiments thereof, which is to be read in connectionwith the accompanying drawings. The various features of the drawings arenot to scale as the illustrations are for clarity in facilitating oneskilled in the art in understanding the invention in conjunction withthe detailed description.

FIG. 1 is an exemplary networked computer environment, in accordancewith one embodiment of the present invention.

FIG. 2 illustrates a modification count tracking system flowchart of theoperational steps carried out by a program to negatively resize acollection instance, in accordance with one embodiment of the presentinvention.

FIG. 3 illustrates a deletion rate to addition rate comparison flowchartof the operational steps carried out by a program to negatively resize acollection instance, in accordance with one embodiment of the presentinvention.

FIG. 4 illustrates an addition rate tracking flowchart of theoperational steps carried out by a program to negatively resize acollection instance, in accordance with one embodiment of the presentinvention.

FIG. 5 is a block diagram of internal and external components ofcomputers and servers depicted in FIG. 1 according to at least oneembodiment.

FIG. 6 depicts a cloud computing environment according to an embodimentof the present invention.

FIG. 7 depicts abstraction model layers according to an embodiment ofthe present invention.

DETAILED DESCRIPTION

Detailed embodiments of the claimed structures and methods are disclosedherein; however, it can be understood that the disclosed embodiments aremerely illustrative of the claimed structures and methods that may beembodied in various forms. This invention may, however, be embodied inmany different forms and should not be construed as limited to theexemplary embodiments set forth herein. Rather, these exemplaryembodiments are provided so that this disclosure will be thorough andcomplete and will fully convey the scope of this invention to thoseskilled in the art. In the description, details of well-known featuresand techniques may be omitted to avoid unnecessarily obscuring thepresented embodiments.

Embodiments of the present invention are related to the field ofcomputing, and more particularly to virtual machine garbage collection.The following described exemplary embodiments provide a system, method,and program product to, among other things, automatically resize acollection instance by identifying execution points in a virtualmachine. Therefore, the present embodiment has the capacity to improvethe technical field of virtual machine garbage collection by allowing acollection instance to hold elements in an efficient manner and reducethe overhead of untimely resizing of the collection instance.

As previously described, garbage collection in a virtual machineenvironment, such as a Java virtual machine, relates to an automaticpart of a process that manages runtime memory used by the program.Garbage collection may relieve programmer overhead required to manuallydeallocate resources in a program. The Java collections frameworkprovides an efficient organization and utilization of real world datawith the garbage collector providing enhanced allocation, deallocationmechanisms to it. The Java collections framework may be a group ofclasses and interfaces implementing a set of frequently used andreusable data structures.

The Java collections framework may be a powerful non-persistent dataorganization architecture, which provides software modules with a highdegree of reusability. The reusability aspect of the Java collectionsframework may be prominent due to the rich set of features best suitedfor the recording, retrieving, and processing of user defined,heterogeneous data records. The heterogeneity of the records may be inrelation to the type, content, and volume of the data. Among otherthings, one of the vital features of the collection instances is thedynamic growth, which allows a collection object to be internallyresized to contain new entry requests transparent to the user.

To achieve internal, manual resizing, many techniques implement aninternal data structure, such as an array. When created, the datastructure may be sized so as to hold the current elements present withinthe Java collections framework. When more elements are added, a largerdata structure may be created to allow for expansion. For this type ofresizing, the elements within the original data structure may be copiedfrom the original, smaller data structure to the new, larger datastructure. Once the new data structure is created and populated, theoriginal data structure may be discarded. The new data structure may bekept as the internal buffer for the Java collections framework and usedfor further collection operations.

If elements are continuously added to the Java collection instance,creation of a new data structure each time elements are added may berecursive and demanding on system resources. Additionally, when elementsare removed from the Java collections framework, many common methods ofcollection do not track holes produced in the backing array. Therefore,when a data structure array becomes very large in relation to theelements within the data structure array, shrinking of the datastructure array to efficiently accommodate the objects may be needed. Assuch, it may be advantageous, among other things, to implement acollection system that identifies execution points in a Java virtualmachine instance where a collection instance may be automaticallyresized to store elements in an efficient manner while reducing theoverhead of untimely resizing.

Garbage collection is a powerful feature in modern languages, includingJava. The memory management within the language runtime may identify thememory crunch in the program and may initiate a collection operation ata predefined point where the application threads are temporarily frozento accommodate the memory restructure. At any given point in time duringthe execution of a program, garbage collection roughly corresponds tothe memory demanding situations in the application. Garbage collectionmay include three phases during the implementation of a virtual machine,such as a marking phase, a sweeping phase, and a compaction phase. Themarking phase may traverse through live objects by inspecting thedefining class type of each object encountered. Since some class typesimplement collection behaviors and some class types do not, determiningthe class type of an encountered object may identify whether theencountered object is also a collection type object.

According to one embodiment, objects within a data structure may beidentified as collection type objects by traversing the data structureand determining whether a defining object class implements a collectioninterface. A collection data structure may then be resized at identifiedgarbage collection points based on preconfigured criteria. The garbagecollection points may be identified by tracking the operations thatoccurred to an object, such as a historical pattern of objectinsertions, deletion of elements, and resizing history.

Each modification to the collection, including variants of additions andvariants of deletions mapping to one operation, may be tracked using ascalar counter within the object. The scalar counter value may be cachedat each garbage collection point within the same object. Another scalarvalue may be employed to track the number of garbage collection cyclesthrough which the modification counter remained constant. If themodification count that was cached remains the same as the currentmodification count after a predefined number of garbage collectioncycles (e.g. 32 garbage collection cycles) and the occupancy ratio ofthe collection is below a predefined threshold (e.g. 70%) then thecollection may be shrunk by creating a new backing structure with thesize equal to the current occupation, copying the old content into thenew structure, and discarding the old structure. Each time amodification is made to the collection, the cached value and the garbagecollection count may be reset. Since a collection that has not beenmodified for a specified number of consecutive collection cycles and hasbeen under-utilized during each collection cycle may possess a tendencyto remain in the same state in the future, the collection may berestructured so unwanted memory within the structure can be reclaimedinto the system.

The present invention may be a system, a method, and/or a computerprogram product at any possible technical detail level of integration.The computer program product may include a computer readable storagemedium (or media) having computer readable program instructions thereonfor causing a processor to carry out aspects of the present invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, configuration data for integrated circuitry, oreither source code or object code written in any combination of one ormore programming languages, including an object oriented programminglanguage such as Smalltalk, C++, or the like, and procedural programminglanguages, such as the “C” programming language or similar programminglanguages. The computer readable program instructions may executeentirely on the user's computer, partly on the user's computer, as astand-alone software package, partly on the user's computer and partlyon a remote computer or entirely on the remote computer or server. Inthe latter scenario, the remote computer may be connected to the user'scomputer through any type of network, including a local area network(LAN) or a wide area network (WAN), or the connection may be made to anexternal computer (for example, through the Internet using an InternetService Provider). In some embodiments, electronic circuitry including,for example, programmable logic circuitry, field-programmable gatearrays (FPGA), or programmable logic arrays (PLA) may execute thecomputer readable program instructions by utilizing state information ofthe computer readable program instructions to personalize the electroniccircuitry, in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the blocks may occur out of theorder noted in the Figures. For example, two blocks shown in successionmay, in fact, be executed substantially concurrently, or the blocks maysometimes be executed in the reverse order, depending upon thefunctionality involved. It will also be noted that each block of theblock diagrams and/or flowchart illustration, and combinations of blocksin the block diagrams and/or flowchart illustration, can be implementedby special purpose hardware-based systems that perform the specifiedfunctions or acts or carry out combinations of special purpose hardwareand computer instructions.

The following described exemplary embodiments provide a system, method,and program product to implement a garbage collection system thatidentifies execution points in a virtual machine instance where a javacollection instance may be resized to store elements in an efficientmanner while reducing the overhead of untimely resizing. According to atleast one implementation, counters may be implemented in various javacollection instances to monitor the memory demands during a preconfigureseries of garbage collection cycles. If the memory demands of the systemremain below a preconfigured occupancy ratio for the preconfigurednumber of garbage collection cycles, the collection structure may beautomatically resized to efficiently accommodate the demands of theapplication process.

Referring to FIG. 1, an exemplary networked computer environment 100 isdepicted, in accordance with one embodiment. The networked computerenvironment 100 may include a client computing device 110 and a server120 interconnected via a communication network 130. According to atleast one implementation, the networked computer environment 100 mayinclude a plurality of client computing devices 110 and servers 120,only one of each being shown for illustrative brevity.

The communication network 130 may include various types of communicationnetworks, such as a wide area network (WAN), local area network (LAN), atelecommunication network, a wireless network, a public switched networkand/or a satellite network. The communications network 130 may includeconnections, such as wire, wireless communication links, or fiber opticcables. It may be appreciated that FIG. 1 provides only an illustrationof one implementation and does not imply any limitations with regard tothe environments in which different embodiments may be implemented. Manymodifications to the depicted environments may be made based on designand implementation requirements.

The client computing device 110 may include a processor 104 and a datastorage device 106 that is enabled to host a software program 108, aCollection Instance Resizing Program 112A and a Java Virtual Machine(JVM) 114A, and communicate with the server 120 via the network 130, inaccordance with one embodiment of the invention. The client computingdevice 110 may be, for example, a mobile device, a telephone, a personaldigital assistant, a netbook, a laptop computer, a tablet computer, adesktop computer, or any type of computing device capable of running aprogram and accessing a network. As will be discussed with reference toFIG. 5, the client computing device 110 may include internal components502 a and external components 504 a, respectively.

The server computer 120 may be a laptop computer, netbook computer,personal computer (PC), a desktop computer, or any programmableelectronic device capable of hosting a Collection Instance ResizingProgram 112B and a Java Virtual Machine (JVM) 114B and communicatingwith the client computing device 110 via the network 130, in accordancewith embodiments of the invention. As will be discussed with referenceto FIG. 5, the server computer 120 may include internal components 502 band external components 504 b, respectively. The server 120 may alsooperate in a cloud computing service model, such as Software as aService (SaaS), Platform as a Service (PaaS), or Infrastructure as aService (IaaS). The server 120 may also be located in a cloud computingdeployment model, such as a private cloud, community cloud, publiccloud, or hybrid cloud.

According to the present embodiment, the Collection Instance ResizingProgram 112A, 112B may be a program capable of resizing a collectiondata structure based on comparison of preconfigured criteria, such as anunchanged occupancy ratio below a shrinkage threshold value but over athreshold garbage collection count, a changed occupancy ratio stillwithin the shrinkage threshold with a rate of addition less than a rateof deletion, a changed occupancy ratio within the shrinkage threshold towarrant a negative resizing to save memory. The Collection InstanceResizing Program 112A, 112B is explained in further detail below withrespect to FIG. 2, FIG. 3, and FIG. 4.

Referring now to FIG. 2, a modification count tracking system flowchart200 of the operational steps carried out by a program to negativelyresize a collection instance is depicted, in accordance with oneembodiment of the present invention. The modification count trackingsystem flowchart 200 may demonstrate negatively resizing a collectionobject based on a predefined threshold size for the occupancy ratio of acollection by tracking each modification to the collection object andtracking garbage collection cycles, which the collection objectsurvived, without undergoing any modification. At 202, the CollectionInstance Resizing Program 112A, 112B (FIG. 1) identifies the collectionobjects from all live objects stored within the JVM 114A, 114B (FIG. 1).A live object within a collection instance may relate to elementsactively stored within the memory of the JVM 114A, 114B (FIG. 1). TheCollection Instance Resizing Program 112A, 112B (FIG. 1) may identifythe live objects stored in memory within the JVM 114A, 114B (FIG. 1)from all stored objects. The Collection Instance Resizing Program 112A,112B (FIG. 1) may then analyze the identified live objects to, in turn,identify the collection type objects (i.e. collection objects) storedwithin the JVM 114A, 114B (FIG. 1). By traversing all live objects toidentify the collection objects, the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may be capable of determining whichcollection objects may be eligible for garbage collection.

Next at 204, the Collection Instance Resizing Program 112A, 112B(FIG. 1) analyzes a modification count of the collected objects. TheCollection Instance Resizing Program 112A, 112B (FIG. 1) analyzes themodification count of the identified collection objects by comparing themodification count of each identified collection object with a cachedcount associated with each identified collection object. The CollectionInstance Resizing Program 112A, 112B (FIG. 1) may track eachmodification made to each identified collection object by utilizing ascalar counter. The scalar counter may increment by one whenever amodification is made to an identified collection object. The value ofthe scalar counter is cached at each garbage collection point within thesame identified collection object upon the completion of a garbagecollection cycle. For example, when a modification is made to anidentified collection object for the first time, the scalar counterimplemented by the Collection Instance Resizing Program 112A, 112B(FIG. 1) may increment the modification count by one unit. If this isthe only modification made to the identified collection object duringthe current garbage collection cycle, the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may cache the modification count equalingone modification. Additionally, the Collection Instance Resizing Program112A, 112B (FIG. 1) may reset the cached value and a garbage collectioncycle count each time a modification is made to the collection. Thegarbage collection cycle count may be recorded by another tracker torecord the number of garbage collection cycles a java collectioninstance may encounter without a modification being made to the datastructure.

Then at 206, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the modification count is equal to thecached count. According to one implementation, the method may continuealong the modification count tracking system flowchart 200, if themodification count is equal to the cached count. If the CollectionInstance Resizing Program 112A, 112B (FIG. 1) determines themodification count is equal to the cached count (step 206, “YES”branch), the Collection Instance Resizing Program 112A, 112B (FIG. 1)may continue to step 208 to determine if the garbage collection cyclecount is greater than a preconfigured threshold value. If the CollectionInstance Resizing Program 112A, 112B (FIG. 1) determines themodification count is not equal to the cached count (step 206, “NO”branch), the Collection Instance Resizing Program 112A, 112B (FIG. 1)may reset the scalar counters of the collection instance and terminatesince modifications may have been made to the identified collectionobjects within the collection instance. Therefore, restructuring thecollection instance may not be needed.

If the Collection Instance Resizing Program 112A, 112B (FIG. 1)determines the modification count is the same as the cached count, thenthere may not be any modification changes to the identified collectionobjects from the last garbage collection point to the current garbagecollection point. When no modifications to the data structure are made,the Collection Instance Resizing Program 112A, 112B (FIG. 1) maydetermine resizing of the data structure is necessary since the memorydemand of the program executed within the JVM 114A, 114B (FIG. 1) may belower than the allocated memory.

Next at 208, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the garbage collection cycle count for thegarbage collection instance is greater than a preconfigured thresholdvalue, such as 32 garbage collection cycles. As previously described, agarbage collection cycle count tracker may be utilized to record thenumber of garbage collection cycles a garbage collection instance mayencounter without a modification being made to the data structure.According to one implementation, the method may continue along themodification count tracking system flowchart 200, if the garbagecollection cycle count is greater than the preconfigured thresholdvalue. When the garbage collection cycle count reaches a value greaterthan the preconfigured threshold value, then the Collection InstanceResizing Program 112A, 112B (FIG. 1) may determine that the applicationhosted within JVM 114A, 114B (FIG. 1) has been under memory constraintfor a period equivalent to the preconfigured threshold value and mayeffectively be considered dormant with respect to modifications. If theCollection Instance Resizing Program 112A, 112B (FIG. 1) determines thegarbage collection cycle count is greater than the preconfiguredthreshold value (step 208, “YES” branch), the Collection InstanceResizing Program 112A, 112B (FIG. 1) may continue to step 212 todetermine if the occupancy ratio is less than the shrink threshold. Ifthe Collection Instance Resizing Program 112A, 112B (FIG. 1) determinesthe garbage collection cycle count is not greater than the preconfiguredthreshold value (step 208, “NO” branch), the Collection InstanceResizing Program 112A, 112B (FIG. 1) may continue to step 210 toincrement the garbage collection count tracker in the object. Forexample, if the preconfigured threshold value is 32 garbage collectioncycles, the Collection Instance Resizing Program 112A, 112B (FIG. 1) mayproceed to determine if the occupancy ratio is less than the shrinkthreshold value when the garbage collection count is greater than 32.Similarly, the Collection Instance Resizing Program 112A, 112B (FIG. 1)may proceed to increment the collection cycle count by one unit when thegarbage collection count is less than 32.

Then at 210, the Collection Instance Resizing Program 112A, 112B(FIG. 1) increments the garbage collection count tracker in the objectby one unit. If the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines that the garbage collection cycle count is below thepreconfigured threshold, the Collection Instance Resizing Program 112A,112B (FIG. 1) may need to increment the garbage collection count trackerby one unit to account for the current garbage collection cycle whenperforming future garbage collection cycles. For example, if theCollection Instance Resizing Program 112A, 112B (FIG. 1) determines acurrent garbage collection cycle is the fifth consecutive garbagecollection cycle where the modification count is equal to the cachedcount, which means no modifications have been made to the identifiedcollection objects in five garbage collection cycles, then theCollection Instance Resizing Program 112A, 112B (FIG. 1) may incrementthe garbage collection count tracker by one unit to indicate that fivegarbage collection cycles have been performed where no modificationshave been made to the collection objects. Upon incrementing the garbagecollection count tracker in the object by one unit, the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may terminate.

Next at 212, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the occupancy ratio is less than the shrinkthreshold. The occupancy ratio may be actively used memory by the JVM114A, 114B (FIG. 1) compared to the total available memory within thecollection instance. The shrink threshold may be a preconfiguredthreshold value relating to the actively used memory in the JVM 114A,114B (FIG. 1) in relation to the total available memory within thecollection instance. When the occupancy ratio falls below thepreconfigured shrink threshold, the Collection Instance Resizing Program112A, 112B (FIG. 1) may determine the collection instance may beresized. According to one implementation, the method may continue alongthe modification count tracking system flowchart 200, if the occupancyratio is less than the shrink threshold. If the Collection InstanceResizing Program 112A, 112B (FIG. 1) determines the occupancy ratio isless than the shrink threshold (step 212, “YES” branch), the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may continue to step 214to restructure the object to the previous expansion boundary nearest tothe current volume. If the Collection Instance Resizing Program 112A,112B (FIG. 1) determines the occupancy ratio is not less than the shrinkthreshold (step 212, “NO” branch), the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may reset the scalar counters with respectto the collection instance in question and terminate. For example, ifthe preconfigured shrink threshold is set to 70% of the total collectioninstance, then the Collection Instance Resizing Program 112A, 112B(FIG. 1) may determine to shrink the collection instance when theoccupancy ratio of the actively used memory to total collection instancesize falls below 70%.

Then at 214, the Collection Instance Resizing Program 112A, 112B(FIG. 1) restructures the object to the previous expansion boundarynearest to the current volume. When the Collection Instance ResizingProgram 112A, 112B (FIG. 1) determines the modification count and thecached count have been equal for the preconfigured number of garbagecollection cycles and the occupancy ratio has fallen below thepreconfigured shrink threshold, then the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may restructure (e.g. shrink) the collectioninstance since a collection instance that meets these criteria may havea continued tendency to be under-utilized in the future. Therefore, theCollection Instance Resizing Program 112A, 112B (FIG. 1) may restructurethe collection instance in order to reclaim unwanted system memory. TheCollection Instance Resizing Program 112A, 112B (FIG. 1) may restructurethe collection instance by creating a new backing structure with a sizeequal to the current occupation volume. Content currently stored on theold structure may be copied to the newly created structure. Furthermore,the old structure may be discarded or deleted since the new structuremay be a more efficient use of resources for the JVM 114A, 114B (FIG.1). Additionally, the Collection Instance Resizing Program 112A, 112B(FIG. 1) may reset each scalar counter (i.e. tracker) when thecollection instance is shrunk. Therefore, the Collection InstanceResizing Program 112A, 112B (FIG. 1) may be capable of monitoring thecollection instance for a new resizing if the previously describedcriteria (i.e. modification count equal to cached count, garbagecollection count equal to a preconfigured value, and occupancy ratioless than the preconfigured shrink threshold) are satisfied. Uponrestructuring the object to the previous expansion boundary nearest tothe current volume, the Collection Instance Resizing Program 112A, 112B(FIG. 1) may terminate.

It may be appreciated that FIG. 2 provides only an illustration of oneimplementation and does not imply any limitations with regard to howdifferent embodiments may be implemented. Many modifications to thedepicted environments may be made based on design and implementationrequirements. For example, although the present embodiment is describedwith respect to a Java virtual machine, any type of virtual machine,such as a Parrot virtual machine and Microsoft®.NET Framework (Microsoftand all Microsoft-based trademarks and logos are trademarks orregistered trademarks of Microsoft Corporation and/or its affiliates)may be used during implementation.

Referring now to FIG. 3, a deletion rate to addition rate comparisonflowchart 300 of the operational steps carried out by a program tonegatively resize a collection instance is depicted, in accordance withone embodiment of the present invention. The deletion rate to additionrate comparison flowchart 300 may demonstrate a method to negativelyresize the collection based on a predefined threshold size for theoccupancy ratio of the collection, when an addition rate of a collectionobject is less than the deletion rate of the collection object. At 302,the Collection Instance Resizing Program 112A, 112B (FIG. 1) identifiesthe collection objects from all live objects stored within the JVM 114A,114B (FIG. 1). As previously described, a live object within acollection instance may relate to elements actively stored within thememory of the JVM 114A, 114B (FIG. 1). The Collection Instance ResizingProgram 112A, 112B (FIG. 1) may identify the live objects stored inmemory within the JVM 114A, 114B (FIG. 1) from all stored objects. TheCollection Instance Resizing Program 112A, 112B (FIG. 1) may thenanalyze the identified live objects to, in turn, identify the collectiontype objects (i.e. collection objects) stored within the JVM 114A, 114B(FIG. 1). By traversing all live objects to identify the collectionobjects, the Collection Instance Resizing Program 112A, 112B (FIG. 1)may be capable of determining which collection objects may be eligiblefor garbage collection.

Next at 304, the Collection Instance Resizing Program 112A, 112B(FIG. 1) analyzes an addition count and a deletion count of thecollected objects. The Collection Instance Resizing Program 112A, 112B(FIG. 1) may separately track the insertions and removals to thecollection, and variants of insertions and removals to the collection,using two scalar counters within each collection object. The CollectionInstance Resizing Program 112A, 112B (FIG. 1) may analyze the additioncount and deletion count of the identified collection objects tracked bythe scalar counters by comparing the addition count and deletion countof each identified collection object with a cached count ofmodifications associated with each identified collection object. Eachscalar counter may increment the addition count or deletion count by onewhenever a corresponding addition or deletion is made to an identifiedcollection object. The value of each scalar counter is cached at eachgarbage collection point within the same identified collection objectupon the completion of a garbage collection cycle. For example, when adeletion is made to an identified collection object for the first time,the scalar counter implemented by the Collection Instance ResizingProgram 112A, 112B (FIG. 1) to track deletions may increment thedeletion count by one unit. If this is the only deletion made to theidentified collection object during the current garbage collectioncycle, the Collection Instance Resizing Program 112A, 112B (FIG. 1) maycache the deletion count equaling one deletion. Furthermore, theCollection Instance Resizing Program 112A, 112B (FIG. 1) may calculate adeletion rate and an addition rate by using the deletion count and theaddition count tracked by the scalar counters over a period of time.Additionally, the Collection Instance Resizing Program 112A, 112B(FIG. 1) may reset the cached value and the garbage collection cyclecount each time the deletion rate is greater than the addition rate. Aspreviously described, the garbage collection cycle count may be recordedby a tracker to record the number of garbage collection cycles a garbagecollection instance may encounter without a modification being made tothe data structure.

Then at 306, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the deletion rate is greater than theaddition rate. According to one implementation, the method may continuealong the deletion rate to addition rate comparison flowchart 300, ifthe deletion rate is greater than the addition rate. If the CollectionInstance Resizing Program 112A, 112B (FIG. 1) determines the deletioncount is greater than the addition count (step 306, “YES” branch), theCollection Instance Resizing Program 112A, 112B (FIG. 1) may continue tostep 308 to determine if the garbage collection cycle count is greaterthan a preconfigured threshold value. If the Collection InstanceResizing Program 112A, 112B (FIG. 1) determines the deletion count isnot greater than the addition count (step 306, “NO” branch), theCollection Instance Resizing Program 112A, 112B (FIG. 1) may reset thecounters for the collection object and terminate since modifications mayhave been made to the identified collection objects within thecollection instance. Therefore, restructuring the collection instancemay not be needed. In another embodiment, the Collection InstanceResizing Program 112A, 112B (FIG. 1) may compare the rate of deletion tothe rate of addition to each collection object.

If the Collection Instance Resizing Program 112A, 112B (FIG. 1)determines the deletion count is the greater than the addition count,then there may not be any modification changes to the identifiedcollection objects from the last garbage collection point to the currentgarbage collection point. In fact, when the deletion count is greaterthan the addition count, the Collection Instance Resizing Program 112A,112B (FIG. 1) may determine that less memory allocated to the collectionobject is needed since more entries are being deleted than are beingadded to the collection object. When no deletions to an object exceedthe additions, the Collection Instance Resizing Program 112A, 112B(FIG. 1) may determine resizing of the data structure is necessary sincethe memory demand of the program executed within the JVM 114A, 114B(FIG. 1) may be lower than the allocated memory.

Next at 308, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the garbage collection cycle count for thegarbage collection instance is greater than a preconfigured thresholdvalue, such as 32 garbage collection cycles. As previously described,the garbage collection cycle count tracker may be utilized to record thenumber of garbage collection cycles a garbage collection instance mayencounter without a modification being made to the data structure.According to one implementation, the method may continue along thedeletion rate to addition rate comparison flowchart 300, if the garbagecollection cycle count is greater than the preconfigured thresholdvalue. When the garbage collection cycle count reaches a value greaterthan the preconfigured threshold value, then the Collection InstanceResizing Program 112A, 112B (FIG. 1) may determine that the applicationhosted within JVM 114A, 114B (FIG. 1) has been under memory constraintfor a period equivalent to the preconfigured threshold value and mayeffectively be considered dormant with respect to modifications. If theCollection Instance Resizing Program 112A, 112B (FIG. 1) determines thegarbage collection cycle count is greater than the preconfiguredthreshold value (step 308, “YES” branch), the Collection InstanceResizing Program 112A, 112B (FIG. 1) may continue to step 312 todetermine if the occupancy ratio is less than the shrink threshold. Ifthe Collection Instance Resizing Program 112A, 112B (FIG. 1) determinesthe garbage collection cycle count is not greater than the preconfiguredthreshold value (step 308, “NO” branch), the Collection InstanceResizing Program 112A, 112B (FIG. 1) may continue to step 310 toincrement the garbage collection count tracker in the object. Forexample, if the preconfigured threshold value is 32 garbage collectioncycles, the Collection Instance Resizing Program 112A, 112B (FIG. 1) mayproceed to determine if the occupancy ratio is less than the shrinkthreshold value when the garbage collection count is greater than 32.Similarly, the Collection Instance Resizing Program 112A, 112B (FIG. 1)may proceed to increment the collection cycle count by one unit when thegarbage collection count is less than 32.

Then at 310, the Collection Instance Resizing Program 112A, 112B(FIG. 1) increments the garbage collection count tracker in the objectby one unit. If the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines that the garbage collection cycle count is below thepreconfigured threshold, the Collection Instance Resizing Program 112A,112B (FIG. 1) may need to increment the garbage collection count trackerby one unit to account for the current garbage collection cycle whenperforming future garbage collection cycles. For example, if theCollection Instance Resizing Program 112A, 112B (FIG. 1) determines acurrent garbage collection cycle is the fifth consecutive garbagecollection cycle where the deletion rate is greater than the additionrate, then the Collection Instance Resizing Program 112A, 112B (FIG. 1)may increment the garbage collection count tracker by one unit toindicate that five garbage collection cycles have been performed wherethe deletion rate is less than the addition rate have been made to thecollection objects. Upon incrementing the garbage collection counttracker in the object by one unit, the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may terminate.

Next at 312, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the occupancy ratio is less than the shrinkthreshold. The occupancy ratio may be actual actively used memory by theJVM 114A, 114B (FIG. 1) compared to the total available memory withinthe collection instance. The shrink threshold may be a preconfiguredvalue relating to the actual actively used memory in the JVM 114A, 114B(FIG. 1) in relation to the total available memory within the collectioninstance. When the occupancy ratio falls below the preconfigured shrinkthreshold, the Collection Instance Resizing Program 112A, 112B (FIG. 1)may determine the collection instance may be resized. According to oneimplementation, the method may continue along the deletion rate toaddition rate comparison flowchart 300, if the occupancy ratio is lessthan the shrink threshold. If the Collection Instance Resizing Program112A, 112B (FIG. 1) determines the occupancy ratio is less than theshrink threshold (step 312, “YES” branch), the Collection InstanceResizing Program 112A, 112B (FIG. 1) may continue to step 314 torestructure the object to the previous expansion boundary nearest to thecurrent volume. If the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines the occupancy ratio is not less than the shrinkthreshold (step 312, “NO” branch), the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may reset the counters and terminate. Forexample, if the preconfigured shrink threshold is set to 70% of thetotal collection instance, then the Collection Instance Resizing Program112A, 112B (FIG. 1) may determine to shrink the collection instance whenthe occupancy ratio of the actively used memory to total collectioninstance size falls below 70%.

Then at 314, the Collection Instance Resizing Program 112A, 112B(FIG. 1) restructures the collection object to the previous expansionboundary nearest to the current volume. When the Collection InstanceResizing Program 112A, 112B (FIG. 1) determines the deletion rate isgreater than the addition rate and the occupancy ratio has fallen belowthe preconfigured shrink threshold, then the Collection InstanceResizing Program 112A, 112B (FIG. 1) may restructure (e.g. shrink) thecollection instance since a collection instance that meets thesecriteria may have a continued tendency to be under-utilized in thefuture. Therefore, the Collection Instance Resizing Program 112A, 112B(FIG. 1) may restructure the collection instance in order to reclaimunwanted system memory. The Collection Instance Resizing Program 112A,112B (FIG. 1) may restructure the collection instance by creating a newbacking structure with a size equal to the current occupation volume.Content currently stored on the old structure may be copied to the newlycreated structure. Furthermore, the old structure may be discarded sincethe new structure may be a more efficient use of resources for the JVM114A, 114B (FIG. 1). Additionally, the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may reset each scalar counter (i.e. tracker)when the collection instance is shrunk. Therefore, the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may be capable ofmonitoring the collection instance for a new resizing if the previouslydescribed criteria (i.e. deletion rate greater than addition rate,garbage collection count equal to a preconfigured value, and occupancyratio less than the preconfigured shrink threshold) are satisfied. Uponrestructuring the object to the previous expansion boundary nearest tothe current volume, the Collection Instance Resizing Program 112A, 112B(FIG. 1) may terminate.

Referring now to FIG. 4, an addition rate tracking flowchart 400 of theoperational steps carried out by a program to negatively resize acollection instance is depicted, in accordance with one embodiment ofthe present invention. The addition rate tracking flowchart 400 maydemonstrate a method to negatively resizing the collection based on apredefined threshold size for the occupancy ratio of the collection andby tracking additions and an addition rate to collection objects therebyensuring the addition rate is within a containment limit of a predefinedshrinkage threshold for the collection. At 402, the Collection InstanceResizing Program 112A, 112B (FIG. 1) identifies the collection objectsfrom all live objects stored within the JVM 114A, 114B (FIG. 1). Aspreviously described, a live object within a collection instance mayrelate to elements actively stored within the memory of the JVM 114A,114B (FIG. 1). The Collection Instance Resizing Program 112A, 112B(FIG. 1) may identify the live objects stored in memory within the JVM114A, 114B (FIG. 1) from all stored objects. The Collection InstanceResizing Program 112A, 112B (FIG. 1) may then analyze the identifiedlive objects to, in turn, identify the collection type objects (i.e.collection objects) stored within the JVM 114A, 114B (FIG. 1). Bytraversing all live objects to identify the collection objects, theCollection Instance Resizing Program 112A, 112B (FIG. 1) may be capableof determining which collection objects may be eligible for garbagecollection.

Next at 404, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the occupancy ratio is less than the shrinkthreshold. As previously described, the occupancy ratio may be actualactively used memory by the JVM 114A, 114B (FIG. 1) compared to thetotal size of the collection instance. The shrink threshold may be apreconfigured value relating to the actual actively used memory in theJVM 114A, 114B (FIG. 1) in relation to the total size of the collectioninstance. When the occupancy ratio falls below the preconfigured shrinkthreshold, the Collection Instance Resizing Program 112A, 112B (FIG. 1)may determine the collection instance may be resized. According to oneimplementation, the method may continue along the addition rate trackingflowchart 400, if the occupancy ratio is less than the shrink threshold.If the Collection Instance Resizing Program 112A, 112B (FIG. 1)determines the occupancy ratio is less than the shrink threshold (step404, “YES” branch), the Collection Instance Resizing Program 112A, 112B(FIG. 1) may continue to step 406 to determine whether the additioncount is equal to the cached count. If the Collection Instance ResizingProgram 112A, 112B (FIG. 1) determines the occupancy ratio is not lessthan the shrink threshold (step 404, “NO” branch), the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may reset the counters andterminate. For example, if the preconfigured shrink threshold is set to70% of the total collection instance, then the Collection InstanceResizing Program 112A, 112B (FIG. 1) may determine to shrink thecollection instance when the occupancy ratio of the actively used memoryto total collection instance size falls below 70%.

Then at 406, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the addition count is equal to the cachedcount. As previously described, the Collection Instance Resizing Program112A, 112B (FIG. 1) may track the insertions to the collection using ascalar counter within each collection object. Unlike the embodimentdescribed in FIG. 3, the present embodiment may not track deletions tothe identified collection objects because, irrespective of anyinsertions or removals happening in the object, as long as the additionsare not causing the occupancy ratio to cross the shrinkage limit thecollection may still be under-utilized. Therefore, the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may implement a scalarcounter to track additions to the collection but increment the counteronly for additions when the collection is already above thepreconfigured shrink threshold. The Collection Instance Resizing Program112A, 112B (FIG. 1) may analyze the addition count of the identifiedcollection objects tracked by the scalar counter by comparing theaddition count of each identified collection object with a cached countof additions associated with each identified collection object. Thevalue of each scalar counter is cached at each garbage collection pointwithin the same identified collection object upon the completion of agarbage collection cycle. According to one implementation, the methodmay continue along the addition rate tracking flowchart 400, if theaddition count is equal to the cached count. If the Collection InstanceResizing Program 112A, 112B (FIG. 1) determines the addition count isequal to the cached count (step 406, “YES” branch), the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may continue to step 408to determine if the garbage collection cycle count is greater than apreconfigured threshold value. If the Collection Instance ResizingProgram 112A, 112B (FIG. 1) determines the addition count is not equalto the cached count (step 406, “NO” branch), the Collection InstanceResizing Program 112A, 112B (FIG. 1) may terminate.

Next at 408, the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines whether the garbage collection cycle count for thegarbage collection instance is greater than a preconfigured thresholdvalue, such as 32 garbage collection cycles. A garbage collection cyclecount tracker may be utilized to record the number of garbage collectioncycles a garbage collection instance may encounter without amodification being made to the data structure. According to oneimplementation, the method may continue along the addition rate trackingflowchart 400, if the garbage collection cycle count is greater than thepreconfigured threshold value. When the garbage collection cycle countreaches a value greater than the preconfigured threshold value, then theCollection Instance Resizing Program 112A, 112B (FIG. 1) may determinethat the application hosted within JVM 114A, 114B (FIG. 1) has beenunder memory constraint for a period equivalent to the preconfiguredthreshold value and may effectively be considered dormant with respectto modifications. If the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines the garbage collection cycle count is greater thanthe preconfigured threshold value (step 408, “YES” branch), theCollection Instance Resizing Program 112A, 112B (FIG. 1) may continue tostep 412 to restructure the object to the previous expansion boundarynearest to the current volume. If the Collection Instance ResizingProgram 112A, 112B (FIG. 1) determines the garbage collection cyclecount is not greater than the preconfigured threshold value (step 408,“NO” branch), the Collection Instance Resizing Program 112A, 112B(FIG. 1) may continue to step 410 to increment the garbage collectioncount tracker in the object. For example, if the preconfigured thresholdvalue is 32 garbage collection cycles, the Collection Instance ResizingProgram 112A, 112B (FIG. 1) may proceed to restructure the object to theprevious expansion boundary nearest to the current volume when thegarbage collection count is greater than 32. Similarly, the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may proceed to incrementthe collection cycle count by one unit when the garbage collection countis less than 32.

Then at 410, the Collection Instance Resizing Program 112A, 112B(FIG. 1) increments the garbage collection count tracker in the objectby one unit. If the Collection Instance Resizing Program 112A, 112B(FIG. 1) determines that the garbage collection cycle count is below thepreconfigured threshold, the Collection Instance Resizing Program 112A,112B (FIG. 1) may need to increment the garbage collection count trackerby one unit to account for the current garbage collection cycle whenperforming future garbage collection cycles. For example, if theCollection Instance Resizing Program 112A, 112B (FIG. 1) determines acurrent garbage collection cycle is the fifth consecutive garbagecollection cycle where the addition count is equal to the cached count,then the Collection Instance Resizing Program 112A, 112B (FIG. 1) mayincrement the garbage collection count tracker by one unit to indicatethat five garbage collection cycles have been performed. Uponincrementing the garbage collection count tracker in the object by oneunit, the Collection Instance Resizing Program 112A, 112B (FIG. 1) mayterminate.

Then at 412, the Collection Instance Resizing Program 112A, 112B(FIG. 1) restructures the object to the previous expansion boundarynearest to the current volume. When the Collection Instance ResizingProgram 112A, 112B (FIG. 1) determines the addition count and the cachedcount have been equal for the preconfigured number of garbage collectioncycles and the occupancy ratio has fallen below the preconfigured shrinkthreshold, then the Collection Instance Resizing Program 112A, 112B(FIG. 1) may restructure (e.g. shrink) the collection instance since acollection instance that meets these criteria may have a continuedtendency to be under-utilized in the future. Therefore, the CollectionInstance Resizing Program 112A, 112B (FIG. 1) may restructure thecollection instance in order to reclaim unwanted system memory. TheCollection Instance Resizing Program 112A, 112B (FIG. 1) may restructurethe collection instance by creating a new backing structure with a sizeequal to the current occupation volume. Content currently stored on theold structure may be copied to the newly created structure. Furthermore,the old structure may be discarded since the new structure may be a moreefficient use of resources for the JVM 114A, 114B (FIG. 1).Additionally, the Collection Instance Resizing Program 112A, 112B(FIG. 1) may reset each scalar counter (i.e. tracker) when thecollection instance is restructure. Therefore, the Collection InstanceResizing Program 112A, 112B (FIG. 1) may be capable of monitoring thecollection instance for a new resizing if the previously describedcriteria (i.e. addition count equal to cached count, garbage collectioncount equal to a preconfigured value, and occupancy ratio less than thepreconfigured shrink threshold) are satisfied. Upon restructuring theobject to the previous expansion boundary nearest to the current volume,the Collection Instance Resizing Program 112A, 112B (FIG. 1) mayterminate.

FIG. 5 is a block diagram 500 of internal and external components ofclient computing device 110 and server 120 depicted in FIG. 1 inaccordance with an embodiment of the present invention. It should beappreciated that FIG. 5 provides only an illustration of oneimplementation and does not imply any limitations with regard to theenvironments in which different embodiments may be implemented. Manymodifications to the depicted environments may be made based on designand implementation requirements.

Data processing system 502, 504 is representative of any electronicdevice capable of executing machine-readable program instructions. Dataprocessing system 502, 504 may be representative of a smart phone, acomputer system, PDA, or other electronic devices. Examples of computingsystems, environments, and/or configurations that may represented bydata processing system 502, 504 include, but are not limited to,personal computer systems, server computer systems, thin clients, thickclients, hand-held or laptop devices, multiprocessor systems,microprocessor-based systems, network PCs, minicomputer systems, anddistributed cloud computing environments that include any of the abovesystems or devices.

Client computing device 110 (FIG. 1) and server 120 (FIG. 1) may includerespective sets of internal components 502 a,b and external components502 a,b illustrated in FIG. 5. Each of the sets of internal components502 include one or more processors 520, one or more computer-readableRAMs 522 and one or more computer-readable ROMs 524 on one or more buses526, and one or more operating systems 528 and one or morecomputer-readable tangible storage devices 530. The one or moreoperating systems 528, the Collection Instance Resizing Program 112A(FIG. 1) and the JVM 114A (FIG. 1) in client computer 110 (FIG. 1), andthe Collection Instance Resizing Program 112B (FIG. 1) and the JVM 114B(FIG. 1) in server 120 (FIG. 1) are stored on one or more of therespective computer-readable tangible storage devices 530 for executionby one or more of the respective processors 520 via one or more of therespective RAMs 522 (which typically include cache memory). In theembodiment illustrated in FIG. 5, each of the computer-readable tangiblestorage devices 530 is a magnetic disk storage device of an internalhard drive. Alternatively, each of the computer-readable tangiblestorage devices 530 is a semiconductor storage device such as ROM 524,EPROM, flash memory or any other computer-readable tangible storagedevice that can store a computer program and digital information.

Each set of internal components 502 a,b also includes a R/W drive orinterface 532 to read from and write to one or more portablecomputer-readable tangible storage devices 538 such as a CD-ROM, DVD,memory stick, magnetic tape, magnetic disk, optical disk orsemiconductor storage device. A software program, such as the CollectionInstance Resizing Program 112A, 112B (FIG. 1) and the JVM 114A, 114B(FIG. 1), can be stored on one or more of the respective portablecomputer-readable tangible storage devices 538, read via the respectiveR/W drive or interface 532 and loaded into the respective hard drive530.

Each set of internal components 502 a,b also includes network adaptersor interfaces 536 such as a TCP/IP adapter cards, wireless Wi-Fiinterface cards, or 3G or 4G wireless interface cards or other wired orwireless communication links. The Collection Instance Resizing Program112A (FIG. 1) and JVM 114A (FIG. 1) in client computer 110 (FIG. 1) andthe Collection Instance Resizing Program 112B (FIG. 1) and the JVM 114B(FIG. 1) in server 120 (FIG. 1) can be downloaded to client computer 110(FIG. 1) and server 120 (FIG. 1) from an external computer via a network(for example, the Internet, a local area network or other, wide areanetwork) and respective network adapters or interfaces 536. From thenetwork adapters or interfaces 536, the Collection Instance ResizingProgram 112A (FIG. 1) and the JVM 114A (FIG. 1) in client computer 110(FIG. 1) and the Collection Instance Resizing Program 112B (FIG. 1) andthe JVM 114B (FIG. 1) in server 120 (FIG. 1) are loaded into therespective hard drive 530. The network may comprise copper wires,optical fibers, wireless transmission, routers, firewalls, switches,gateway computers and/or edge servers.

Each of the sets of external components 504 a,b can include a computerdisplay monitor 544, a keyboard 542, and a computer mouse 534. Externalcomponents 504 a,b can also include touch screens, virtual keyboards,touch pads, pointing devices, and other human interface devices. Each ofthe sets of internal components 502 a,b also includes device drivers 540to interface to computer display monitor 544, keyboard 542, and computermouse 534. The device drivers 540, R/W drive or interface 532 andnetwork adapter or interface 536 comprise hardware and software (storedin storage device 530 and/or ROM 524).

It is understood in advance that although this disclosure includes adetailed description on cloud computing, implementation of the teachingsrecited herein are not limited to a cloud computing environment. Rather,embodiments of the present invention are capable of being implemented inconjunction with any other type of computing environment now known orlater developed.

Cloud computing is a model of service delivery for enabling convenient,on-demand network access to a shared pool of configurable computingresources (e.g. networks, network bandwidth, servers, processing,memory, storage, applications, virtual machines, and services) that canbe rapidly provisioned and released with minimal management effort orinteraction with a provider of the service. This cloud model may includeat least five characteristics, at least three service models, and atleast four deployment models.

Characteristics are as follows:

On-demand self-service: a cloud consumer can unilaterally provisioncomputing capabilities, such as server time and network storage, asneeded automatically without requiring human interaction with theservice's provider.

Broad network access: capabilities are available over a network andaccessed through standard mechanisms that promote use by heterogeneousthin or thick client platforms (e.g., mobile phones, laptops, and PDAs).

Resource pooling: the provider's computing resources are pooled to servemultiple consumers using a multi-tenant model, with different physicaland virtual resources dynamically assigned and reassigned according todemand. There is a sense of location independence in that the consumergenerally has no control or knowledge over the exact location of theprovided resources but may be able to specify location at a higher levelof abstraction (e.g., country, state, or datacenter).

Rapid elasticity: capabilities can be rapidly and elasticallyprovisioned, in some cases automatically, to quickly scale out andrapidly released to quickly scale in. To the consumer, the capabilitiesavailable for provisioning often appear to be unlimited and can bepurchased in any quantity at any time.

Measured service: cloud systems automatically control and optimizeresource use by leveraging a metering capability at some level ofabstraction appropriate to the type of service (e.g., storage,processing, bandwidth, and active user accounts). Resource usage can bemonitored, controlled, and reported providing transparency for both theprovider and consumer of the utilized service.

Service Models are as follows:

Software as a Service (SaaS): the capability provided to the consumer isto use the provider's applications running on a cloud infrastructure.The applications are accessible from various client devices through athin client interface such as a web browser (e.g., web-based e-mail).The consumer does not manage or control the underlying cloudinfrastructure including network, servers, operating systems, storage,or even individual application capabilities, with the possible exceptionof limited user-specific application configuration settings.

Platform as a Service (PaaS): the capability provided to the consumer isto deploy onto the cloud infrastructure consumer-created or acquiredapplications created using programming languages and tools supported bythe provider. The consumer does not manage or control the underlyingcloud infrastructure including networks, servers, operating systems, orstorage, but has control over the deployed applications and possiblyapplication hosting environment configurations.

Infrastructure as a Service (IaaS): the capability provided to theconsumer is to provision processing, storage, networks, and otherfundamental computing resources where the consumer is able to deploy andrun arbitrary software, which can include operating systems andapplications. The consumer does not manage or control the underlyingcloud infrastructure but has control over operating systems, storage,deployed applications, and possibly limited control of select networkingcomponents (e.g., host firewalls).

Deployment Models are as follows:

Private cloud: the cloud infrastructure is operated solely for anorganization. It may be managed by the organization or a third party andmay exist on-premises or off-premises.

Community cloud: the cloud infrastructure is shared by severalorganizations and supports a specific community that has shared concerns(e.g., mission, security requirements, policy, and complianceconsiderations). It may be managed by the organizations or a third partyand may exist on-premises or off-premises.

Public cloud: the cloud infrastructure is made available to the generalpublic or a large industry group and is owned by an organization sellingcloud services.

Hybrid cloud: the cloud infrastructure is a composition of two or moreclouds (private, community, or public) that remain unique entities butare bound together by standardized or proprietary technology thatenables data and application portability (e.g., cloud bursting forload-balancing between clouds).

A cloud computing environment is service oriented with a focus onstatelessness, low coupling, modularity, and semantic interoperability.At the heart of cloud computing is an infrastructure comprising anetwork of interconnected nodes.

Referring now to FIG. 6, illustrative cloud computing environment 50 isdepicted. As shown, cloud computing environment 50 comprises one or morecloud computing nodes 10 with which local computing devices used bycloud consumers, such as, for example, personal digital assistant (PDA)or cellular telephone 54A, desktop computer 54B, laptop computer 54C,and/or automobile computer system 54N may communicate. Nodes 10 maycommunicate with one another. They may be grouped (not shown) physicallyor virtually, in one or more networks, such as Private, Community,Public, or Hybrid clouds as described hereinabove, or a combinationthereof. This allows cloud computing environment 50 to offerinfrastructure, platforms and/or software as services for which a cloudconsumer does not need to maintain resources on a local computingdevice. It is understood that the types of computing devices 54A-N shownin FIG. 6 are intended to be illustrative only and that computing nodes10 and cloud computing environment 50 can communicate with any type ofcomputerized device over any type of network and/or network addressableconnection (e.g., using a web browser).

Referring now to FIG. 7 a set of functional abstraction layers 700provided by cloud computing environment 50 (FIG. 6) is shown. It shouldbe understood in advance that the components, layers, and functionsshown in FIG. 7 are intended to be illustrative only and embodiments ofthe invention are not limited thereto. As depicted, the following layersand corresponding functions are provided:

Hardware and software layer 60 includes hardware and softwarecomponents. Examples of hardware components include: mainframes 61; RISC(Reduced Instruction Set Computer) architecture based servers 62;servers 63; blade servers 64; storage devices 65; and networks andnetworking components 66. In some embodiments, software componentsinclude network application server software 67 and database software 68.

Virtualization layer 70 provides an abstraction layer from which thefollowing examples of virtual entities may be provided: virtual servers71; virtual storage 72; virtual networks 73, including virtual privatenetworks; virtual applications and operating systems 74; and virtualclients 75.

In one example, management layer 80 may provide the functions describedbelow. Resource provisioning 81 provides dynamic procurement ofcomputing resources and other resources that are utilized to performtasks within the cloud computing environment. Metering and Pricing 82provide cost tracking as resources are utilized within the cloudcomputing environment, and billing or invoicing for consumption of theseresources. In one example, these resources may comprise applicationsoftware licenses. Security provides identity verification for cloudconsumers and tasks, as well as protection for data and other resources.User portal 83 provides access to the cloud computing environment forconsumers and system administrators. Service level management 84provides cloud computing resource allocation and management such thatrequired service levels are met. Service Level Agreement (SLA) planningand fulfillment 85 provide pre-arrangement for, and procurement of,cloud computing resources for which a future requirement is anticipatedin accordance with an SLA.

Workloads layer 90 provides examples of functionality for which thecloud computing environment may be utilized. Examples of workloads andfunctions which may be provided from this layer include: mapping andnavigation 91; software development and lifecycle management 92; virtualclassroom education delivery 93; data analytics processing 94;transaction processing 95; and collection instance resizing 96.Collection instance resizing 96 may refer to resizing a garbagecollection instance based predefined criteria, such as a modificationcount associated with a collection object, a deletion rate associatedwith a collection object, an addition rate associated with a collectionobject, an occupancy ratio of a data structure in relation to apreconfigured shrink threshold, and a total number of garbage collectioncycle count.

The descriptions of the various embodiments of the present inventionhave been presented for purposes of illustration, but are not intendedto be exhaustive or limited to the embodiments disclosed. Manymodifications and variations will be apparent to those of ordinary skillin the art without departing from the scope of the describedembodiments. The terminology used herein was chosen to best explain theprinciples of the embodiments, the practical application or technicalimprovement over technologies found in the marketplace, or to enableothers of ordinary skill in the art to understand the embodimentsdisclosed herein.

1. A computer system for collection instance resizing, the computer system comprising: one or more processors, one or more computer-readable memories, one or more computer-readable tangible storage medium, and program instructions stored on at least one of the one or more tangible storage medium for execution by at least one of the one or more processors via at least one of the one or more memories, wherein the computer system is capable of performing a method comprising: identifying, by a processor, at least one collection object among a plurality of live collection objects within a collection framework of a virtual machine, wherein the plurality of live collection objects relates to a plurality of elements actively stored with the virtual machine; determining a current modification count is equal to a cached count based on comparing the current modification count associated with the at least one identified collection object with a cached count associated with each at least one identified collection object, wherein the cached count is a record of a plurality of previous modifications to the at least one identified collection object during a previous garbage collection cycle kept by a scalar counter, and wherein the value of the scalar counter is cached at a garbage collection point within the at least one identified collection object upon a completion of a garbage collection cycle, and wherein the current modification count is a record of a plurality of current modifications to the at least one identified collection object during a current garbage collection cycle; determining a garbage collection cycle count associated with the at least one identified collection object exceeds a value of thirty-two, wherein the garbage collection cycle count is a tally of a plurality of completed garbage collection cycles by the collection framework; determining an occupancy ratio associated with the at least one identified collection object is less than a preconfigured shrink threshold, wherein the occupancy ratio is calculated as a plurality of actively used memory within the collection framework compared to a plurality of total available memory within the collection framework, and wherein the preconfigured shrink threshold is a preconfigured value relating to the plurality of actively used memory within the collection framework compared to the plurality of total available memory within the collection framework; and restructuring the at least one identified collection object based on determining the modification count is equal to the cached count, the garbage collection cycle count exceeds the value of thirty-two, and the occupancy ratio is less than the preconfigured shrink threshold, wherein restructuring the at least one identified collection object includes shrinking the at least one identified collection object to a previous expansion boundary nearest to a current volume of the at least one identified collection object by creating a new backing structure to the collection framework with a size equal to the current volume, copying a plurality of currently stored content on an old backing structure to the created new backing structure, and deleting the old backing structure, and wherein the scalar counter is reset when the at least one identified collection object is shrunk. 